package
{
	import flash.display.Sprite;
	
	import gs.TweenLite;
	import gs.easing.Expo;
	
	[SWF(width=400, height=400, backgroundColor="#000000")]
	public class FlipSymbol extends Sprite
	{
		public var dot:Sprite;
		public var motion:CircularMotion;
		
		public function FlipSymbol()
		{
			dot = new Sprite();
			dot.graphics.beginFill(0xFF0000, 1);
			dot.graphics.drawCircle(0,0,10);
			dot.x = 200;
			dot.y = 200;
			
			this.addChild(dot);
			
			motion = new CircularMotion(this, "dot", 150);
			
			forward();
		}
		
		public function forward():void
		{
			TweenLite.to(motion, 4, {radians:2*Math.PI, ease:Expo.easeInOut, onComplete:reverse});
		}
		
		public function reverse():void
		{
			TweenLite.to(motion, 4, {degrees:0, ease:Expo.easeInOut, onComplete:forward});
		}
	}
}
	import flash.display.DisplayObject;
	

class CircularMotion
{
	protected var _obj:DisplayObject;
	protected var nm:String;
	protected var angle:Number = 0;  // in radians
	protected var r:Number = 0;
	protected var centerX:Number = 0;
	protected var centerY:Number = 0;
	
	public function CircularMotion(obj:DisplayObject, _name:String, radius:Number)
	{
		_obj = obj;
		nm = _name;
		r = radius;
		centerX = _obj[nm].x;
		centerY = _obj[nm].y;
		
		radians = 0;
	}
	
	public function get degrees():Number { return ((angle/Math.PI)*180); }
	public function set degrees(val:Number):void
	{
		radians = (val/180)*Math.PI;
	}
	
	public function get radians():Number { return angle; }
	public function set radians(val:Number):void
	{
		angle = val;
		_obj[nm].x = centerX + Math.cos(angle)*r;
		_obj[nm].y = centerY + Math.sin(angle)*r;
	}
}